package com.wx_zgwl_client;

import com.netflix.appinfo.HealthCheckHandler;
import com.netflix.appinfo.InstanceInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.actuate.health.Status;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.core.env.Environment;
import org.springframework.stereotype.Component;

/**
 * 刘强
 *
 * @author 健康检查处理器  默认30秒执行一次
 * @create 2018-01-14 18:27
 **/
@Component
public class MyHealthCheckHandler implements HealthCheckHandler {
    @Autowired
    private  MyHealthndicator MyHealthndicator;




    @Override
    public InstanceInfo.InstanceStatus getStatus(InstanceInfo.InstanceStatus instanceStatus) {
        Status s =MyHealthndicator.health().getStatus();
        if(s.equals(Status.UP)){
            System.out.print("数据库连接正常"+"---");
            return InstanceInfo.InstanceStatus.UP;
        }else{
            System.out.print("数据库无法连接");
            return InstanceInfo.InstanceStatus.DOWN;
        }
    }
}
